package com.luoluo.controller;

import com.luoluo.pojo.TouristsLeaveWord;
import com.luoluo.pojo.UserTable;
import com.luoluo.service.impl.TouristsLeaveWordServiceImpl;
import com.luoluo.service.impl.UserTableServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestParam;

@Controller
public class UserTableController {

    @Autowired
    UserTableServiceImpl userTableServiceImpl;
    /**
     * 查询留言，按id查询，查询用户数据
     * @return
     */
    @GetMapping("usertable/{id}")
    public String selectById(@PathVariable("id")Integer id, Model model){
        UserTable userTable = userTableServiceImpl.selectByUserId(id);
        model.addAttribute("userTable", userTable);
        System.out.println("用户查询完成..."+userTable);
        return "select";
    }
    /**
     * 查询全部
     */
    @GetMapping("usertable")
    public String index(Model model){
        model.addAttribute( "data", userTableServiceImpl.selectAll());
        return "all";
    }
}